package com.instasale.converters;

import com.instasale.models.Seller;
import com.instasale.services.SellerService;
import org.springframework.core.convert.converter.Converter;

public class StringToSellerConverter implements Converter<String, Seller> {

    private SellerService sellerService;

    public StringToSellerConverter(SellerService sellerService) {
        this.sellerService = sellerService;
    }

    @Override
    public Seller convert(String s) {
        return sellerService.getById(Integer.parseInt(s));
    }
}
